﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Freedom.Models.Interfaces;
using Freedom.Models.Services;
using Freedom.Models;
using Freedom.Models.ViewModels;

namespace Freedom.Controllers
{
    /// <summary>
    /// 手机版联系方式控制器
    /// autor: Penn Yao
    /// </summary>
    [HandleError]
    public class MController : Controller
    {
        MViewModel viewModel;
        IMessageInfoService messageInfoService;

        public MController()
        {
            if (messageInfoService == null)
                messageInfoService = new MessageInfoService();
        }

        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult Post([Bind(Include = "Name, Email, Title, Content")]tb_MessageInfo messageInfo)
        {
            if (messageInfoService != null)
                messageInfoService.addInfo(messageInfo);

            if (viewModel != null)
                viewModel.messageInfo = messageInfo;

            return RedirectToAction("Index", "M");
        }
    }
}
